<template>
	<!-- 海外仓基础库发货记录 -->
	<a-modal title="发货记录" width="80%" :visible="visible" :maskClosable="false" :confirmLoading="confirmLoading"
		@cancel="handleCancel" :footer="null">
		<a-spin :spinning="false">
			<a-form :form="form" layout="inline" labelAlign="right">
				<s-table ref="table" style="margin-top: 15px;" size="default" :columns="columns" :data="loadData" :alert="true">
					<!-- <span slot="file" slot-scope="text">
						<image-preview :images="text" />
					</span> -->
					<span slot="image" slot-scope="text,record">
						<image-preview1 :images="text" :imageUrl="record.imageUrl" />
					</span>
				</s-table>
			</a-form>
		</a-spin>
		<!--  新增编辑详情弹框  -->
		<childNumAddAndEdit ref="childNumAddAndEdit" @ok="$refs.table.refresh(true)" :pid="record.id"
			:materialType="materialType" />
	</a-modal>
</template>

<script>
import {
	sendInfoPage as page
} from '@/api/modular/main/emsorder/emsOrderManage'
import { STable } from '@/components'
export default {
	components: { STable },
	data() {
		return {
			record: {},
			queryParam: {},
			columns: [
				{
					title: '序号',
					width: '80px',
					customRender: (text, record, index) => `${index + 1}`
				},
				{
					title: '发货单号',
					dataIndex: 'orderNumber'
				},
				{
					title: '发货时间',
					dataIndex: 'createTime'
				},
				{
					title: '归属子公司',
					dataIndex: 'orgName'
				},
				{
					title: '发货数量',
					dataIndex: 'number'
				},
				{
					title: '发货方式',
					dataIndex: 'delivery'
				},
				{
					title: '发货凭证',
					dataIndex: 'file',
					width: '100px',
					scopedSlots: { customRender: 'file' }
				},
				{
					title: '备注',
					dataIndex: 'remark'
				},

			],
			// 加载数据方法 必须为 Promise 对象
			loadData: parameter => {
				console.log('record', this.record)
				let query = {
					...this.queryParam,
					...parameter,
					materialId: this.record.materialId
				}
				return page(query).then((res) => {
					console.log('res', res)
					return res.data
				})
			},
			visible: false,
			confirmLoading: false,
			form: this.$form.createForm(this),
		}
	},
	methods: {
		// 初始化方法
		init(record) {
			this.record = { ...record }
			this.visible = true
			this.$refs.table.refresh(true)
		},
		handleOk() {
			this.$refs.table.refresh()
		},
		handleCancel() {
			this.form.resetFields()
			this.visible = false
		}
	}
}
</script>
